package homework3;

public class OList implements IOList {

	Object object;
	IOList rest;

	public OList(Object o, IOList list) {
		this.object = o;
		this.rest = list;
	}

	@Override
	public IOList addElt(Object o) {
		return new OList(o, this);
	}

	@Override
	public IOList remElt(Object o) {
		if (o.equals(object)) {
			return rest;
		}
		return new OList(object, rest.remElt(o));
	}

	@Override
	public boolean hasElt(Object o) {
		return o.equals(object) || rest.hasElt(o);
	}

	@Override
	public int size() {
		return 1 + rest.size();
	}

}
